﻿using System;
using System.Xml.Serialization;

namespace Kiva7.DataClasses
{

    public class Image
    {
        [XmlElement("id")]
        public int Id { get; set; }

        [XmlElement("template_id")]
        public int TemplateId { get; set; }

        private Uri ImageUrl(string imageSize)
        {
            if (TemplateId == 1)
            {
                return CreateImageUri(Id, imageSize);
            }
            return null;
        }

        public static Uri CreateImageUri(int id, string imageSize)
        {
            return new Uri(string.Format("http://www.kiva.org/img/{0}/{1}.jpg", imageSize, id));
        }

        public Uri SmallImageUrl
        {
            get
            {
                return ImageUrl(ImageSize.Small);
            }
        }
        public Uri NormalImageUrl
        {
            get
            {
                return ImageUrl(ImageSize.Normal);
            }
        }
        public Uri MediumImageUrl
        {
            get
            {
                return ImageUrl(ImageSize.Medium);
            }
        }
        public Uri LargeImageUrl
        {
            get
            {
                return ImageUrl(ImageSize.Large);
            }
        }
        public Uri FullSizeImageUrl
        {
            get
            {
                return ImageUrl(ImageSize.FullSize);
            }
        }
    }
}
